<div class="panel-manage">	
	<div class="navbar navbar-inverse">
		<div class="navbar-inner">		
		</div>
	</div>
	<div class="panel-space"></div>
	<table class="table table-striped" style="margin:0 auto;">
		<thead>
			<tr style="background-color:brown; color:#fff;">
				<th>รหัสสั่งซื้อ</th>
				<th></th>					
				<th>ชื่อร้าน</th>
				<th>แพ็คเกจที่สั่งซื้อ</th>
				<th>สถานะสั่งซื้อ</th>
				<th></th>					
			</tr>
		</thead>
		<tbody>		
			<?php for ($i=0; $i<count($data); $i++): ?>
				<tr>
					<td><?php print $data[$i]['PAK_O_CODE']; ?></td>
					<td><img src="<?php print $data[$i]['CAF_IMG_L_FILENAME']; ?>" style="width:30px; height:30px;" /></td>					
					<td><?php print $data[$i]['CAF_TITLE']; ?></td>
					<td><?php print $data[$i]['PAK_NAME']; ?></td>					
						
					<?php if ($data[$i]['PAK_O_STATUS'] == 1): ?>
							<td>ชำระเงินแล้ว</td>
					<?php else: ?>
							<td>ยังไม่ชำระเงิน</td>
					<?php endif; ?>
					<td><a href="#" class="btn btn-mini btn-view-payment">รายละเอียด</a></td>
				</tr>
			<?php endfor; ?>
		</tbody>				
	</table>
	<div class="pagination">
		<?php if ($page_count > 0){?>	
			<ul>
			    <li><a href="<?php print base_url() . 'member/payment?p=1'; ?>">First</a></li>    
			    <?php for ($i=0; $i<$page_count; $i++) {?>
			      	<li><a href="<?php print base_url() . 'member/payment?p=' . ($i+1); ?>"><?php print $i+1; ?></a></li>
			    <?php }?>
			    <li><a href="<?php print base_url() . 'member/payment?p=' . $page_count; ?>">Last</a></li>
			</ul>
		<?php } ?>
	</div>
</div>
<script type="text/javascript">
	function create_view_payment_modal(code){
		var html = '<div id="modal-view-payment" class="modal hide fade">';		
		html += '<div class="modal-header">';
		html += '	<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>';
		html += '	<h3>เพิ่มร้านค้า</h3>';
		html += '</div>';
		html += '<div class="modal-body">';		
		html += '		<div class="control-group">';
		html += '			<label class="control-label" for="acct">ชื่อร้าน</label>';
		html += '			<div class="controls">';
		html += '				<input type="text" id="acct" name="acct">';
		html += '			</div>';
		html += '		</div>';						
		html += '		<div class="control-group">';
		html += '			<label class="control-label">ประเภทร้าน</label>';
		html += '			<div class="controls">';			
		html += '			</div>';
		html += '		</div>';						
		html += '		<div class="control-group">';
		html += '			<label class="control-label" for="accn">ลิงค์ร้าน</label>';
		html += '			<div class="controls">';		
		html += '			</div>';
		html += '		</div>';		
		html += '</div>';
		html += '<div class="modal-footer">';
		html += '	<div id="panel-message" class="text-left"></div>';
		html += '	<button class="btn" data-dismiss="modal" aria-hidden="true">ปิด</button>';		
		html += '</div>';	
		html += '</div>';
		$('body').append(html);
	
		$('#modal-view-payment').modal('show');
		$('#modal-view-payment').on('hide', function(){
			$(this).remove();
		});	

		$.post('<?php print base_url() . 'member/payment/ajax_view'; ?>', { c : code }, function(output){
			alert(output);
		});
	}
	
	$(function(){
		$('.btn-view-payment').click(function(){			
			create_view_payment_modal($(this).parents('tr').children('td:eq(0)').text());
		});
	});
</script>